home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Commun⁄Network / NewsWatcher 2.0d17 Source / source / about.c next >
Encoding:
C/C++ Source or Header  |  1993-10-07  |  3.1 KB  |  114 lines  |  [TEXT/KAHL]

  1. /*----------------------------------------------------------------------------
  2.  
  3.     about.c
  4.  
  5.     This module presents the about box.
  6.     
  7.     Portions copyright © 1990, Apple Computer.
  8.     Portions copyright © 1993, Northwestern University.
  9.  
  10. ----------------------------------------------------------------------------*/
  11.  
  12. #include <string.h>
  13.  
  14. #include "glob.h"
  15. #include "about.h"
  16. #include "dlgutil.h"
  17. #include "util.h"
  18. #include "prefs.h"
  19.  
  20.  
  21.  
  22. #define    kAboutID            128        /* About box dialog */
  23. #define kAboutText             128        /* resource id of about box text 'TEXT' resource */
  24.  
  25. #define kBigIconPictItem    2        /* item number of big icon pict */
  26. #define kLogoPictItem        3        /* item number of logo pict */
  27. #define kAboutBoxUserItem     5        /* item number of user item for text */
  28.  
  29. #define kBigIconPictColor    128        /* resource id of big icon color picture */
  30. #define kBigIconPictBW        129        /* resource id of big icon B&W picture */
  31. #define kLogoPictColor        130     /* resource id of logo color picture */
  32. #define kLogoPictBW            131     /* resource id of logo B&W picture */
  33.  
  34.  
  35.  
  36. static short gMagicCookie;
  37.     
  38.  
  39.  
  40. /*----------------------------------------------------------------------------
  41.     AboutBoxFilter 
  42.     
  43.     About box dialog filter.
  44. ----------------------------------------------------------------------------*/
  45.  
  46. static pascal Boolean AboutBoxFilter (DialogPtr dlg, EventRecord *theEvent, short *itemHit)
  47. {
  48.     char key;
  49.  
  50.     if (theEvent->what == keyDown && (theEvent->modifiers & cmdKey) != 0) {
  51.         key = theEvent->message & charCodeMask;
  52.         if (key == '1' || key == '2') {
  53.             gMagicCookie = key - '0';
  54.             *itemHit = ok;
  55.             return true;
  56.         }
  57.     }
  58.     return DialogFilter(dlg, theEvent, itemHit);
  59. }
  60.  
  61.  
  62.  
  63. /*----------------------------------------------------------------------------
  64.     DoAboutBox
  65.     
  66.     Present the about box.
  67. ----------------------------------------------------------------------------*/
  68.  
  69. void DoAboutBox (void)
  70. {
  71.     DialogPtr dlg;
  72.     short item;
  73.     PicHandle bigIconPict, logoPict;
  74.     Handle vers1Resource;
  75.     short bigIconPictID, logoPictID;
  76.     CStr255 sampleNewsServerErrorMessage;
  77.     Handle text;
  78.     short fontNum;
  79.     
  80.     dlg = MyGetNewDialog(kAboutID);
  81.     if (GetPixelDepth(&dlg->portRect) <= 2) {
  82.         bigIconPictID = kBigIconPictBW;
  83.         logoPictID = kLogoPictBW;
  84.     } else {
  85.         bigIconPictID = kBigIconPictColor;
  86.         logoPictID = kLogoPictColor;
  87.     }
  88.     bigIconPict = GetPicture(bigIconPictID);
  89.     HNoPurge((Handle)bigIconPict);
  90.     logoPict = GetPicture(logoPictID);
  91.     HNoPurge((Handle)logoPict);
  92.     DlgSetPict(dlg, kBigIconPictItem, bigIconPict);
  93.     DlgSetPict(dlg, kLogoPictItem, logoPict);
  94.     vers1Resource = GetResource('vers', 1);
  95.     HLock(vers1Resource);
  96.     ParamText((StringPtr)*vers1Resource+6, "\p", "\p", "\p");
  97.     HUnlock(vers1Resource);
  98.     gMagicCookie = 0;
  99.     GetFNum("\pGeneva", &fontNum);
  100.     text = GetResource('TEXT', kAboutText);
  101.     SetItemReadOnly(dlg, kAboutBoxUserItem, text, fontNum, 9);
  102.     MyModalDialog(AboutBoxFilter, &item, false, true);
  103.     MyDisposDialog(dlg);
  104.     HPurge((Handle)bigIconPict);
  105.     HPurge((Handle)logoPict);
  106.     if (gMagicCookie == 1) {
  107.         strcpy(sampleNewsServerErrorMessage, "999 This is a sample news server error message.");
  108.         strcat(sampleNewsServerErrorMessage, CRLF);
  109.         NewsServerErrorMessage("SAMPLE", sampleNewsServerErrorMessage);
  110.     } else if (gMagicCookie == 2) {
  111.         CustomizeNewsWatcher();
  112.     }
  113. }
  114.